package com.xl.basic.entity;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import lombok.NonNull;
import lombok.experimental.Accessors;

/**
 * @author 钟勇
 * Create in 2023/8/17 20:18
 */

@Data
@Accessors(chain = true)
public class SPage{

    @NonNull
    private Integer pageIndex = 1;

    @NonNull
    private Integer pageSize = 10;


    public static <T> Page<T> getPage(SPage param) {
        SPage page = new SPage();
        if (param != null) {
            if (param.getPageIndex() > 0) {
                page.setPageIndex(param.getPageIndex());
            }

            if (param.getPageSize() > 0) {
                page.setPageSize(param.getPageSize());
            }
        }

        return new Page<>(page.pageIndex, page.pageSize);
    }

}
